package com.gg.registration.order.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Collections;


/**
 * Author：  chenjunjia
 * Date：    2022/4/19 0:12
 * WeChat：  China_JoJo_
 */
@Configuration
@MapperScan(basePackages = {"com.gg.registration.order.mapper"})
public class MybatisPlusConfig {

    /**
     * 配置分页插件  否则分页查询的
     * total、orders、countId、maxLimit、pages 等值不是 0 就是 null
     */
    @Bean
    public PaginationInnerInterceptor paginationInnerInterceptor(){
        return new PaginationInnerInterceptor();
    }
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
        mybatisPlusInterceptor.setInterceptors(Collections.singletonList(paginationInnerInterceptor()));
        return mybatisPlusInterceptor;
    }


}
